package org.jeecg.modules.article.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.article.service.ClickLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO: 实现用户的点赞功能
 *
 *
 * @author ZhangHaoyu
 */
@Api(tags = "点赞")
@RestController
@RequestMapping(value = "/phil/clicklike")
@Slf4j
public class ClickLike {
    @Autowired
    ClickLikeService clickLikeService;

    @AutoLog(value = "判断是否已经点赞")
    @ApiOperation(value="判断是否已经点赞", notes="判断是否已经点赞")
    @GetMapping(value = "/isclicklike")
    public Result<?> IsClickLike(String articleid, String userid){
        Boolean isclicklike = clickLikeService.IsClickLike(articleid,userid);
      return Result.OK(isclicklike) ;

    }
//    @AutoLog(value = "新增点赞信息")
//    @ApiOperation(value = "新增点赞信息" , notes ="新增点赞信息")
//    @GetMapping(value = "/insertclicklike")
//    public Result<?> InsertClickLike(String articleid ,String userid){
//        int result = clickLikeService.InsertClickLike(articleid,userid);
//        return Result.ok(result);
//    }

    @AutoLog(value = "删除点赞信息")
    @ApiOperation(value = "删除点赞信息" ,notes ="删除点赞信息")
    @GetMapping(value = "/deleteclicklike")
    public Result<?> DelteClickLike(String articleid,String userid){
        int result = clickLikeService.DeleteClickLike(articleid,userid);
        return  Result.ok(result);

    }

    @AutoLog(value = "新增点赞信息")
    @ApiOperation(value = "新增点赞信息" , notes ="新增点赞信息")
    @PostMapping(value = "/insertclicklike")
    public Result<?> InsertClickLike(String articleid ,
                                     String userid){
        int result = clickLikeService.InsertClickLike(articleid,userid);
        return Result.ok(result);
    }
}
